﻿//========================================================= 
/**@file PrintFollower.h
 * @brief 
 * 
 * @date 2018-06-18   13:15:17
 * @author Zhyioo 
 * @version 1.0
 */ 
//--------------------------------------------------------- 
#ifndef _LIBZHOUYB_PRINTFOLLOWER_H_
#define _LIBZHOUYB_PRINTFOLLOWER_H_
//--------------------------------------------------------- 
#include "../ILogCat.h"
//--------------------------------------------------------- 
namespace zhou_yb {
namespace extension {
namespace logcat {
//--------------------------------------------------------- 
/// 直接使用printf使用的日志跟随器封装
class PrintFollower : public LogCatFollower
{
protected:
    ByteBuilder _buff;
public:
    LogCatFollowerConstructor(PrintFollower)

    void operator()(const char* fmt, ...)
    {
        if(!IsEnable())
            return;

        _buff.Clear();
        _buff.Append(ByteArray(_layout.c_str(), _layout.length()));

        va_list args;
        va_start(args, fmt);
        _buff.Format(fmt, args);
        va_end(args);

        _appender->append(_lv, _tag, _buff.GetString());
    }
};
//--------------------------------------------------------- 
} // namespace logcat
} // namespace extension
} // namespace zhou_yb
//--------------------------------------------------------- 
#endif // _LIBZHOUYB_PRINTFOLLOWER_H_
//========================================================= 